const request = require('request')

async function main() {
    var options = {
        'method': 'POST',
        'url': 'https://aip.baidubce.com/rpc/2.0/ernievilg/v1/txt2img?access_token=24.3d0e4431644edc52f52c9b7614448451.2592000.1679477569.282335-30590257',
        'headers': {
                'Content-Type': 'application/json',
                'Accept': 'application/json'
        },
        body: JSON.stringify({
                "text": "美女",
                "resolution": "1024*1024",
                "style": "洛丽塔"
        })
    };

    request(options, function (error, response) {
        if (error) throw new Error(error);
        console.log(response.body);
    });
}

main();